*===============================================================================
*
*					WORKER BELIEFS ABOUT OUTSIDE OPTIONS
*		(c)	Simon Jaeger, Christopher Roth, Nina Roussille, Benjamin Schoefer
*							  2023 December 5
*						   	   	 Local Data 
*
*===============================================================================


********************************************************************************
*								Table A04									   *
********************************************************************************

use "$temp/experiment1.dta", clear

* calculate SOEP-IAB means

matrix J=J(8,5,.)

cap noisily gen fulltime = 1
cap noisily gen nobs = 1

local n = 0
foreach var in nobs gender age pretaxwageearning tenure fulltime pretreatment_wagechange_pct_w2 {
	
	local n = `n'+1
	
	if "`var'"=="nobs" {
		su `var'
		matrix J[`n',3] = r(N)
		
		su `var' if treatmentinfo==0
		matrix J[`n',4] = r(N)
		
		su `var' if treatmentinfo==1
		matrix J[`n',5] = r(N)
	}
	
	if "`var'"!="nobs" {
		su `var'
		matrix J[`n',3] = r(mean)
		
		su `var' if treatmentinfo==0
		matrix J[`n',4] = r(mean)
		
		su `var' if treatmentinfo==1
		matrix J[`n',5] = r(mean)
	}
	
	* SOEP-IAB averages, both FT and PT
	if "`var'"=="nobs" local mean = 514 // from table 1 of the paper (which uses Table01)
	if "`var'"=="age" local mean = 44.6
	if "`var'"=="pretaxwageearning" local mean = 39221.813/12 // annual to monthly wage
	if "`var'"=="tenure" local mean = 11.2
	if "`var'"=="gender" local mean = 0.482
	if "`var'"=="fulltime" local mean = 0.718
	if "`var'"=="pretreatment_wagechange_pct_w2" local mean = -1.211
	matrix J[`n',1] = `mean'	
	* SOEP-IAB only FT
	if "`var'"=="nobs" local mean = 369 // from IAB run, dofile Table01
	if "`var'"=="age" local mean = 44.6
	if "`var'"=="pretaxwageearning" local mean = 45679.285/12 // annual to monthly wage
	if "`var'"=="tenure" local mean = 11.8
	if "`var'"=="gender" local mean = 0.328
	if "`var'"=="fulltime" local mean = 1
	if "`var'"=="pretreatment_wagechange_pct_w2" local mean = -1.560
	matrix J[`n',2] = `mean'
	
	
}

frmttable using "$tab/TableA04.tex", tex fragment statmat(J) replace ///
ctitle("" , "SOEP-IAB Mean", "SOEP-IAB Mean FT" ,"Online Survey Mean", "Online Control Mean", " Online Treatment Mean") ///
sdec(0\3\1\0\1\3\3\3) ///
rtitles("\textbf{General Stats}  & \\ &  \\ Number of Respondents" ///
\ "Share of Women" \ "Age in Years"  \ "Pre-Tax Wage (in EUR, per Month)"  ///
 \ "Tenure in Years" \ "Full-time Employed" \ ///
"\\ \textbf{Beliefs} & \\ & \\ Pretreatment Beliefs: Wage Change (in \%)") 
